package com.bili.bili_data_api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bili.bili_data_api.dao.mapper.GuomanMapper;
import com.bili.bili_data_api.dao.mapper.RimanMapper;
import com.bili.bili_data_api.dao.pojo.Guoman;
import com.bili.bili_data_api.dao.pojo.Riman;
import com.bili.bili_data_api.service.ComicService;
import com.bili.bili_data_api.vo.ComicVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

@Service
public class ComicServiceImpl implements ComicService {

    @Autowired
    private GuomanMapper guomanMapper;
    @Autowired
    private RimanMapper rimanMapper;

    @Override
    public ComicVo getComicType() {
        ComicVo comicVo = new ComicVo();
//        QueryWrapper<Riman> queryWrapper2 = new QueryWrapper<>();
//        queryWrapper2.last("limit 6");
        List<Riman> rimanList = rimanMapper.selectList(null);
        List<String> typeList = new ArrayList<>();
        List<Integer> rNumList = new ArrayList<>();
        QueryWrapper<Guoman> queryWrapper = new QueryWrapper<>();
        queryWrapper.last("limit 9");
        List<Guoman> guomanList = guomanMapper.selectList(queryWrapper);
        for (Riman riman : rimanList) {
            typeList.add(riman.getStyle());
            rNumList.add(riman.getNum());
        }
        List<Integer> gNumList = new ArrayList<>();
        for (Guoman guoman : guomanList) {
            gNumList.add(guoman.getNum());
        }
        comicVo.setNumList1(gNumList);
        comicVo.setTypeList(typeList);
        comicVo.setNumList2(rNumList);
        return comicVo;
    }
}
